package ch.fusun.baron.basic.command;

import ch.fusun.baron.basic.initialization.PlayerInitializer;
import ch.fusun.baron.core.command.GameCommand;
import ch.fusun.baron.core.initialization.GameInitializationUtil;
import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.core.rmi.User;
import ch.fusun.baron.player.Dynasty;

/**
 * Sets the {@link Dynasty} name of the User
 */
public class SetDynastyNameCommand extends GameCommand {

	@Inject
	private transient GameInitializationUtil util;

	private String name;
	private User user;

	/**
	 * Kryo
	 */
	public SetDynastyNameCommand() {
	}

	/**
	 * @param name
	 *            The name of the {@link Dynasty}
	 * @param user
	 *            The user
	 */
	public SetDynastyNameCommand(String name, User user) {
		this.name = name;
		this.user = user;
	}

	@Override
	public boolean isAllowed() {
		return true;
	}

	@Override
	public void execute() {
		util.get(PlayerInitializer.class).setDynastyName(user, name);
	}
}
